//
//  PayForViewController.m
//  YaDiuDiu
//
//  Created by 欧洪飞 on 2017/8/23.
//  Copyright © 2017年 jy. All rights reserved.
//

#import "PayForViewController.h"

#import "PayCell.h"
@interface PayForViewController ()<UITableViewDelegate,UITableViewDataSource>{
    NSArray *array1;
    NSArray *array2;
}

@property (nonatomic,strong)UITableView *tableView;

@end

@implementation PayForViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = COLOR_RGB(242, 242, 242, 1);
    [self showNav:@"支付"];
    array1 = @[@"微信2",@"支付宝-(1)",@"银联2",@"钱包-(1)"];
    array2 = @[@"微信支付",@"支付宝支付",@"银联支付",@"余额支付"];
    
    [self loadUI];
    
}

- (void)loadUI{
    UILabel *lab1 = [[UILabel alloc] initWithFrame:CGRectMake(16, 16+64, 80, 18)];
    lab1.text = @"订单说明";
    lab1.font = [UIFont systemFontOfSize:16.0];
    [self.view addSubview:lab1];
    
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, lab1.frame.origin.y+lab1.frame.size.height+10, ScreenWidth, 65.0)];
    view1.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view1];
    
    UILabel *lab2 = [[UILabel alloc] initWithFrame:CGRectMake(16, 10, 220, 21)];
    lab2.text = @"查看房源“渝北区大竹林”";
    lab2.font = [UIFont systemFontOfSize:15.0];
    [view1 addSubview:lab2];
    
    //
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0, view1.frame.origin.y+view1.frame.size.height+20, ScreenWidth, 50.0)];
    view2.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view2];
    
    UILabel *lab3 = [[UILabel alloc] initWithFrame:CGRectMake(16, 16, 80, 18)];
    lab3.text = @"支付金额:";
    lab3.font = [UIFont systemFontOfSize:14.0];
    [view2 addSubview:lab3];
    
    UILabel *lab4 = [[UILabel alloc] initWithFrame:CGRectMake(lab3.frame.origin.x+lab3.frame.size.width, 16, 80, 18)];
    lab4.text = @"1元";
    lab4.textColor = [UIColor redColor];
    lab4.font = [UIFont systemFontOfSize:14.0];
    [view2 addSubview:lab4];
    
    UILabel *lab5 = [[UILabel alloc] initWithFrame:CGRectMake(16, view2.frame.origin.y+view2.frame.size.height+10, 150, 18)];
    lab5.text = @"选择支付方式";
    lab5.font = [UIFont systemFontOfSize:16.0];
    [self.view addSubview:lab5];
    //667 568
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, lab5.frame.origin.y+lab5.frame.size.height+10, ScreenWidth, 50*4) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.scrollEnabled = NO;
    [self.view addSubview:_tableView];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(25, _tableView.frame.origin.y+_tableView.frame.size.height+20, ScreenWidth-50, 45);
    btn.backgroundColor = [UIColor redColor];
    [btn setTitle:@"去支付" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    btn.layer.cornerRadius = 5.0;
    [self.view addSubview:btn];
}

#pragma -mark UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return array2.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellId = @"Cell";
    PayCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (!cell) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"PayCell" owner:nil options:nil] lastObject];
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
//    NSString *str = [array1 objectAtIndex:indexPath.row];
//    cell.imageMethod.image = [UIImage imageNamed:str];
//    cell.labT.text = array2[indexPath.row];
    cell.imageView.image = [UIImage imageNamed:array1[indexPath.row]];
    cell.textLabel.text = array2[indexPath.row];
    
    if (indexPath.row == 3) {
        cell.textLabel.text = @"   余额支付";
        cell.imageView.frame = CGRectMake(30, 0, 25, 28);
        cell.imageView.image = [UIImage imageNamed:@"钱包-(1)"];
    }
    
    
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50.0;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
